package com.example.task1.ui.AllService.life;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.LifeWeatherBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class LifeWeatherTimeAdapter extends BaseAdapter<LifeWeatherBean.DataDTO.TodayDTO.HoursDTO> {

    private List<LifeWeatherBean.DataDTO.TodayDTO.HoursDTO> mData = new ArrayList<>();
    private Context context;
    private TextView tvWeather;
    private TextView tvTemperature;
    private TextView tvTime;

    public LifeWeatherTimeAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<LifeWeatherBean.DataDTO.TodayDTO.HoursDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.lifeweathertimelist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<LifeWeatherBean.DataDTO.TodayDTO.HoursDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, LifeWeatherBean.DataDTO.TodayDTO.HoursDTO date) {
        tvWeather.setText(date.getWeather());
        tvTime.setText(date.getHour());
        tvTemperature.setText(date.getTemperature() + "℃");
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View view) {
        tvWeather = (TextView) view.findViewById(R.id.tv_weather);
        tvTemperature = (TextView) view.findViewById(R.id.tv_temperature);
        tvTime = (TextView) view.findViewById(R.id.tv_time);
    }
}
